<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>无标题文档</title>
<link href="${pageContext.request.contextPath}/css/baStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.0.min.js"></script>
<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/js/baPublicJs.js"></script> --%>
<script src="${pageContext.request.contextPath}/js/jquery.shCircleLoader.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
$(function(){
	//当进入页面进行查看监测是否在运行
	returnStatus('psgeStart');
});

//后台模板扫描按钮ajax请求
function returnStatus(tempColour){
	var scanNurl="";
	if('start'==tempColour){
		monitorStatus("正在启动监测...");
		scanNurl="/baUser/MonitorFile/start.do";
	}else if('stop'==tempColour){
		monitorStatus("正在关闭监测...");
		scanNurl="/baUser/MonitorFile/stop.do";
		$("#"+tempColour).css("background","#D4e7F0");
		$("#"+tempColour).attr("disabled","disabled");
		$("#start").css("background","");//将按钮可用
		$("#start").removeAttr("disabled");//将按钮可用
	}else{
		scanNurl="/baUser/MonitorFile/psgeStart.do";
	}
		$.ajax({
			type:"post", //提交的类型
			url: "${pageContext.request.contextPath}"+scanNurl,//提交地址
		    dataType: 'text',
			success: function(data){ //回调方法
				if('start'==data){
					conversion("start","stop");	
					monitorStatus("已开启");
				}else if('stop'==data){
					$("#stop").css("background","");//将按钮可用
					$("#stop").removeAttr("disabled");//将按钮可用
					monitorStatus("已关闭");
				}else if('not'==data){
					$("#start,#stop").css("background","");//将按钮可用
					$("#start,#stop").removeAttr("disabled");//将按钮可用
				}else if('none'==data){
					 alert("操作失败");	
				}else{
					var r=confirm("请求超时，请重新登陆！");
					if (r==true)
					  {
						window.location.href=projectName+"/login.jsp";
					  }
				}
			 }
			});
}

function conversion(par1,par2){
	$("#"+par1).css("background","#D4e7F0");
	$("#"+par1).attr("disabled","disabled");
	$("#"+par2).css("background","");//将按钮可用
	$("#"+par2).removeAttr("disabled");//将按钮可用
}
function monitorStatus(par1){
	$("#replaceDate").replaceWith("<font style=\"color:red\" id=\"replaceDate\">"+par1+"</font>");
}
</script>
<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">文件夹状态监测</a></li>
    </ul>
    </div>
    <div class="formbody">
    <div class="formtitle"><span>文件夹监测状态选择</span></div>
    <ul class="forminfo">
	    <li class="selectScan" style="padding-left:200px">
	         <h1>文件夹时时检测状态：<font style="color:red" id="replaceDate">未开启</font></h1>
	    </li>
	    <li style="float: left;clear:none"><label>&nbsp;</label>
	        <input id="start" name="" type="button" class="btn" value="启动监测" onclick="returnStatus('start');" style="margin-top: 50px;"/>
	     </li>
	     <li style="float: left;clear:none"><label>&nbsp;</label>
	        <input id="stop" name="" type="button" class="btn" value="关闭监测" onclick="returnStatus('stop');" style="margin-top: 50px;"/>
	     </li>
    </ul>
    
    </div>

</body>

</html>

